/**
 * 将整数n表示为b进制的字符串存储在s中
 */

#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>

void itob(int n, char s[], unsigned b);
void reverse(char s[]);

int main() {
    char s[1000];
    int n = INT_MAX;
    itob(n, s, 26);
    printf("%d\n%s\n", n, s);

    return 0;
}

void itob(int n, char s[], unsigned b) {
    int i, sign;
    unsigned remainder;

    sign = n;

    i = 0;
    do {
        remainder = abs(n % b);
        s[i++] =  remainder + ((remainder < 10)? '0': ('A' - 10));
    } while (n /= b);
    if (sign < 0)
        s[i++] = '-';
    s[i] = '\0';
    reverse(s);
}

void reverse(char s[]) {
    int i, j;
    for (i = 0, j = strlen(s) - 1; i < j; i++, j--)
        s[i] ^= s[j], s[j] ^= s[i], s[i] ^= s[j];
}
